package com.practice.util;

import java.util.regex.Pattern;

/**
 * Created by Administrator on 2016/8/20.
 */
public class RegexUtil {
  /**
   * 验证Email
   *
   * @param email email地址，格式：zhangsan@sina.com，zhangsan@xxx.com.cn，xxx代表邮件服务商
   * @return 验证成功返回true，验证失败返回false
   */
  public static boolean checkEmail(String email) {
    String regex =
        "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?";
    return Pattern.matches(regex, email);
  }
}
